package com.dgsrz.demo.activity;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.dgsrz.demo.R;

/**
 * Created by dgsrz on 15/7/2.
 */
public class DemoActivity extends Activity {

    private GLSurfaceView mGLSurfaceView;
    private DemoGameScene mGameScene;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGameScene = new DemoGameScene(this);

        mGLSurfaceView = new GLSurfaceView(this);
        mGLSurfaceView.setRenderer(mGameScene.new Renderer());
        setContentView(mGLSurfaceView);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_anim:
                mGameScene.getSlider().startAnimation();
                break;

            case R.id.menu_settings:
                // Control Panel not implemented...
                break;

            default:
                break;
        }
        return true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLSurfaceView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLSurfaceView.onPause();
    }
}
